/**
 * 双圆
 * ibio-develop
 * 2008-11-22 17:42
 */
package com.ibio8.components.wave.behavior {
	import com.ibio8.components.wave.WaveBody;
	
	import flash.utils.ByteArray;

	public class DoubleCircle implements IWaveBehavior {
		protected var m_spaceX:Number = 50;
		
		public function show(ba:ByteArray, sp:WaveBody):void {
			//半径，使半径始终等于最长边
			var l:Number = sp.h;
			if (sp.w > sp.h) {
				l = sp.w;
			}
			var radius:Number =  -ba.readFloat() * l + l/10;
			var temp:Number = radius;
			
			var angStep:Number = 2*Math.PI/256;
			var dispX:Number, dispY:Number;
			dispX = sp.w / 2 - m_spaceX;
			dispY = sp.h / 2;
			//左声道
			sp.graphics.moveTo(radius*Math.sin(0)+ dispX, radius *Math.cos(0) + dispY);
			for (var i:Number = 1; i < 256; i++) {
				radius = -ba.readFloat() * l + l/10;
				sp.graphics.lineTo(radius * Math.sin(i * angStep) + dispX, radius * Math.cos(i * angStep) + dispY);
			}
			sp.graphics.lineTo( temp*Math.sin(0)+ dispX, temp *Math.cos(0)+dispY);
			
			//右声道
			radius =  -ba.readFloat() * l + l/10;
			temp = radius;
			dispX += m_spaceX * 2;
			
			sp.graphics.moveTo(radius*Math.sin(0)+ dispX, radius *Math.cos(0) + dispY);

			for ( i =1; i< 256; i++) {
				radius =  -ba.readFloat() * l + l/10;
				sp.graphics.lineTo(radius*Math.sin(i*angStep)+ dispX, radius *Math.cos(i*angStep)+ dispY);
			}
			sp.graphics.lineTo( temp*Math.sin(0)+ dispX, temp *Math.cos(0)+dispY);
		}
	}
}